//
//  TheBlacklistCell.m
//  OnionHome
//
//  Created by fengjie on 2019/9/14.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "TheBlacklistCell.h"

@interface TheBlacklistCell ()
/**左边图标*/
@property (nonatomic,strong)UIImageView*leftImage;
/**名称*/
@property (nonatomic,strong)UILabel*nameLabel;
/**时间*/
@property (nonatomic,strong)UILabel*timerLabel;
/**右边按钮*/
@property (nonatomic,strong)UIButton*rightbutton;

@end

@implementation TheBlacklistCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createUI];
    }
    return self;
}
-(void)createUI{
    
    [self addSubview:self.leftImage];
    [self addSubview:self.nameLabel];
    [self addSubview:self.timerLabel];
    [self addSubview:self.rightbutton];
    
    [self.leftImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(16);
        make.bottom.mas_equalTo(-16);
        make.width.height.mas_equalTo(64);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.leftImage.mas_right).offset(10);
        make.top.mas_equalTo(self.leftImage.mas_top).offset(8);
    }];
    [self.timerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.leftImage.mas_right).offset(10);
        make.bottom.mas_equalTo(self.leftImage.mas_bottom).offset(-8);
    }];
    [self.rightbutton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.leftImage);
        make.right.mas_equalTo(-16);
        make.width.mas_equalTo(56);
        make.height.mas_equalTo(26);
    }];
}

#pragma mark --懒加载

-(UIImageView*)leftImage{
    if(!_leftImage){
        _leftImage=[UIImageView new];
        _leftImage.layer.cornerRadius = 32;
        _leftImage.image = IMAGE_NAMED(@"userIconDefut");
    }
    return _leftImage;
}
-(UILabel*)nameLabel{
    if(!_nameLabel){
        _nameLabel=[UILabel new];
        _nameLabel.textColor = UIColorFromRGB(0x273323);
        _nameLabel.font = PingFangSC_Medium(16);
        _nameLabel.text = @"大鲨鱼";
    }
    return _nameLabel;
}
-(UILabel*)timerLabel{
    if(!_timerLabel){
        _timerLabel=[UILabel new];
        _timerLabel.textColor = UIColorFromRGB(0x959E97);
        _timerLabel.font = BOLDSYSTEMFONT(12);
        NSMutableAttributedString * string = [NSMutableAttributedString makeAttributeString:@"粉丝数" Attribute:^(NSMutableDictionary * _Nonnull attributes) {
            [attributes setValue:PingFangSC_Regular(12) forKey:NSFontAttributeName];
            attributes.Color(UIColorFromRGB(0x454F44));
            
        }];
        [string makeAttributeStringAdd:@" 1234" Attribute:^(NSMutableDictionary * _Nonnull attributes) {
            [attributes setValue:PingFangSC_Regular(12) forKey:NSFontAttributeName];
            attributes.Color(UIColorFromRGB(0x959E97));
        }];
        _timerLabel.attributedText = string;

    }
    return _timerLabel;
}

-(UIButton*)rightbutton{
    if(!_rightbutton){
        _rightbutton=[UIButton buttonWithType:UIButtonTypeCustom];
        [_rightbutton setTitle:@"解除" forState:UIControlStateNormal];
        [_rightbutton setTitleColor:UIColorFromRGB(0xFF7300) forState:UIControlStateNormal];
        _rightbutton.titleLabel.font = PingFangSC_Regular(16);
        ViewBorderRadius(_rightbutton, 3, 1, UIColorFromRGB(0xFF7300));
        
    }
    return _rightbutton;
}


@end
